package org.example.course.controller;

import org.example.course.common.ResultObj;
import org.example.course.domain.Course;
import org.example.course.domain.Standard;
import org.example.course.service.StandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Classname StandardController
 * @Description TODO
 * @Date 2020/5/9 20:57
 * @Created by
 */
@RestController
@RequestMapping("standards")
public class StandardController {

    @Autowired
    private StandardService service;

    /**
     * 创建
     *
     * @param standard
     * @return
     */
    @RequestMapping(value = "", method = RequestMethod.POST)
    public ResultObj create(Standard standard) {
        if (standard    == null) {
            return ResultObj.CREATE_ERROR;
        }
        if (service.create(standard)) {
            return ResultObj.CREATE_SUCCESS;
        }
        return ResultObj.CREATE_ERROR;
    }


    /**
     * 更新
     *
     * @param standard
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public ResultObj update(Standard standard) {
        if (standard == null) {
            return ResultObj.UPDATE_ERROR;
        }
        if (service.update(standard)) {
            return ResultObj.UPDATE_SUCCESS;
        }
        return ResultObj.UPDATE_ERROR;
    }
}
